<?php
	class admin extends common{

		private $admin_id;
		private $admin_table;
		function __construct(){
			$this->admin_id = $_COOKIE['admin_id'];
			$this->admin_table = 'admin';
			parent::__construct();
		}

		/**
		 * 获得管理员信息
		 * @param  [type] $id 
		 * @return [type]     
		 */
		function getAdminInfo($id = ''){
			$id = $id != '' ? $id : $this->admin_id;
			$key = '*';
			$sql = ' `'.$this->admin_table . '` WHERE `id` = "' . $id. '"';
			$info = $this->getInfo($sql,$key);
			return $info;
		}

		/**
		 * 获得管理员列表
		 * @param  string  $where 
		 * @param  string  $key   
		 * @param  integer $page  
		 * @return [type]         
		 */
		function adminList($where = '', $key="*", $page = 0){
			$sql = $this->admin_table. ' where 1=1 ' . $where;
			$sqlnum = $page != 0 ?$sql : '';
			$list = $this -> getList($sql,$sqlnum,$key);
			return $list;
		}

		/**
		 * 更新管理员信息
		 * @param  [type] $arr   
		 * @param  [type] $where 
		 * @return [type]        
		 */
		function adminUpdate($arr, $where){
			$res = $this->update($this->admin_table,$arr,$where);
			return $res;
		}

		/**
		 * 添加管理员
		 * @param  [type] $arr 
		 * @return [type]      
		 */
		function adminAdd($arr){
			if(is_array($arr)){
				$res = $this->insert($this->admin_table, $arr);
				$id = $this->insert_id();
				return $id;
			}
			return false;
		}
	}

?>